import type { EnergySaveOrUpdateParams } from '@/types'

export const defaultFormData: Partial<EnergySaveOrUpdateParams>
  = {
    name: '',
    code: '',
    energyUnit: '',
    referenceCoefficient: '',
    discountFactor: '1',
    discountFactorUnit: '',
  }

export const formRules = generateCurrencyFormRules(
  defaultFormData,
  [],
  {
    code: [{ validator: validateCode, trigger: 'blur' }],
  },
)
function validateCode(_: any, value: any, callback: any) {
  const reg = /^\d{6}$/
  const m = reg.test(value)
  m
    ? callback()
    : callback(new Error('请输入标准6位数字格式！'))
}
